<!DOCTYPE html>
<html lang="zh">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>服务器控制</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <!--标准mui.css-->
    <link rel="stylesheet" href="/static/css/mui.min.css">
    <!--App自定义的css-->
    <link rel="stylesheet" type="text/css" href="/static/css/app.css">
</head>
<body>
<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-back mui-pull-left"></a>
    <h1 class="mui-title">服务列表</h1>
</header>
<div class="mui-content">
    <ul class="mui-table-view" id="list">
    </ul>
</div>
</div>


</body>
<script src="/static/js/mui.min.js"></script>
<script src="/static/js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" charset="UTF-8">
    //mui初始化
    mui.init({
        swipeBack: true //启用右滑关闭功能
    });

    var listData;
    $(document).ready(function () {
        var id = $.getUrlParam("id")
        mui.post('/service/serviceList', {
                id: id
            }, function (data) {
                if (data.code === 200) {
                    listData = data;
                    for (let i = 0; i < data.data.length; i++) {
                        var t1 = "<li class='mui-table-view-cell' onclick='runCmd(" + i + ")' >\n" +
                            "                    <div class='mui-table'>\n" +
                            "                        <div class='mui-table-cell mui-col-xs-10'>\n" +
                            "                            <h4 class='mui-ellipsis'>" + data.data[i].msg + "</h4>\n"
                        var zt;
                        if (data.data[i].isNormal === 1) {
                            zt = "<h5 style='color:LimeGreen;'>状态:正常</h5>\n"
                        } else {
                            zt = "<h5 style='color:red;'>状态:异常</h5>\n"
                        }
                        var t2 = "<p class='mui-h6 mui-ellipsis'>" + listData.data[i].protocol + "://" + listData.data[i].ip + ":" + listData.data[i].port + listData.data[i].path + "</p>" +
                            "                        </div>\n" +
                            "                    </div>\n" +
                            "                </li>"
                        $("#list").append(t1 + zt + t2)
                    }
                } else {
                    mui.toast(data.msg);
                }
            }, 'json'
        );
    })

    function runCmd(id) {
        listData.data[id]
        window.open(listData.data[id].protocol + "://" + listData.data[id].ip + ":" + listData.data[id].port + listData.data[id].path, "_blank")
    }

    (function ($) {
        $.getUrlParam = function (name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]);
            return null;
        }
    })(jQuery);
</script>

</html>